<?php

include('../../../dbconfig.php');

$per_page = 20;

if($_GET)
{
	$page=$_GET['page'];
	$type = $_GET['type'];
	$topic = "หัวข้อ";
	$author = "ผู้เขียน";
	if($type==1){
		$title = "วิเคราะห์และรายงาน";
	}else if($type==4){
		$title = "ปาตานีคาเฟ่";
	}else if($type==5){
		$title = "บรรณาธิการ";
	}else if($type==6){
		$title = "Quote";
		$topic = "คำกล่าว";
	}else if($type==7){
		$title = "ภาคสนามปาตานี";
    }else if($type==8){
		$title = "การ์ตูน";
	}else if($type==9){
		$title = "สื่อสิ่งพิมพ์";
	}else if($type==10){
		$title = "Tupat Tube";
	}else if($type==11){
		$title = "status of the day";
		$topic = "คอมเมนท์";
	}
	else if($type==12){
		$title = "ประชาสัมพันธ์";
	}
}




//get table contents
$start = ($page-1)*$per_page;
$sql = "SELECT article.*,webmaster.firstname   
		FROM article LEFT JOIN webmaster ON article.modified_master_id = webmaster.webmaster_id
		WHERE fix_article_type = $type
		ORDER BY article_id limit $start,$per_page";

$rsd = mysql_query($sql);
?>


<table border="0" id="article_contenttblArticleList">
	 <tr>
		<th width="45px">ลำดับ</th>
		<th width="100px">ผู้เขียน</th>
		<th width="280px"><?=$topic?></th>
		<th width="60px">วันเวลาที่เพิ่ม</th>
		<th width="100px">ผู้ที่เพิ่ม</th>
		<th width="10px">สถานะ</th>
		<th width="10px">แสดง</th>
		<th width="10px">แก้ไข</th>
		<th width="10px">ลบ</th>	
	</tr>
<?php
$i = 1;
//Print the contents
while($row = mysql_fetch_array($rsd))
{
	if($type == 6 || $type == 11)
		$detail = strip_tags(html_entity_decode($row['description']));
	else
		$detail = $row['title'];

?>
	<tr>
		<td class="tdright"><?= $i;?></td>
		<td><?= $row['reference_st'];?></td>
		<td><?= $detail;?></td>
		<td><?= $row['modified_date_time'];?></td>
		<td class="tdcenter"><?= $row['firstname'];?></td>
		<td class="tdcenter">
			<?php if($row['fix_status'] == '0')
					echo "<img src=\"images/cancel.png\" />";
				  else
					echo "<img src=\"images/accept.png\" />"
			?>
		</td>
		<td class="tdcenter">
			<a href="../single.php?id=<?=$row['article_id']?>" target="_blank"><img src="images/application_double.png" width="16" height="16" /></a>
		</td>
		<td class="tdcenter">
			<a href="#" onClick="article_imgEdit_Onclick(<?=$row['article_id']?>)"><img src="images/application_edit.png" width="16" height="16" /></a>
		</td>
		<td class="tdcenter">
			<a href="#" onClick="article_imgDelete_Onclick(<?=$row['article_id'].",'".$row['title']."',".$row['fix_article_type']?>)"><img src="images/application_delete.png" width="16" height="16" /></a>
		</td>
	</tr>
<?php
	$i++;
} 
?>
	</table>